package com.youhp.spire.xls.demo.Data;

import com.spire.xls.*;

import java.awt.*;

public class ReplaceAndHighlight {
    public static void main(String[] args) {

        Workbook workbook = new Workbook();
        workbook.loadFromFile("data/ReplaceAndHighlight.xlsx");

        Worksheet worksheet = workbook.getWorksheets().get(0);

        CellRange[] ranges = worksheet.findAllString("Total", true, true);

        for (CellRange range : ranges)
        {
            //Reset the text, in other words, replace the text
            range.setText("Sum");

            //Set the color
            range.getCellStyle().setColor(Color.yellow);
        }

        workbook.saveToFile("output/ReplaceAndHighlight.xlsx", ExcelVersion.Version2010);

    }
}
